const {
  servicesData,
  updateData,
  deleteData,
  detailData,
} = require('../../controllers/wechat/services.js')

const { verifyToken } = require('../../utils/jwt.js')

const orders = (fastify, options, done) => {
  /**
   * 获取 维修订单
   */
  fastify.get('/wechat/upkeep/list', { preHandler: verifyToken }, servicesData)
  done()

  /**
   * 添加 维修订单
   */
  fastify.post('/wechat/upkeep/list', { preHandler: verifyToken }, updateData)
  done()

  /**
   * 删除 维修订单
   */
  fastify.delete('/wechat/upkeep/list', { preHandler: verifyToken }, deleteData)
  done()

  /**
   * 更新 维修订单
   */
  fastify.put('/wechat/upkeep/list', { preHandler: verifyToken }, updateData)
  done()

  /**
   * 获取 维修订单 详情
   */
  fastify.get(
    '/wechat/upkeep/list/details/:orderNo',
    { preHandler: verifyToken },
    detailData
  )
  done()
}

module.exports = orders
